#include <cstdio>

int main( )
{
    int t, n, k, x[ 101 ], i, count;
    scanf("%d", &t);
    while ( t-- )
    {
        scanf("%d%d", &n, &k);
        for ( i = 1; i <= n; i++ )
            scanf("%d", &x[ i ]);
        count = 0;
        for ( i = 1; i <= n; i++ )
            if ( x[ i ] > x[ k ] )
                count++;
        printf("%d\n", count);
    }
    return 0;
}
